/*

* ------------------------------------------------------------------------
* ------------------------------------------------------------------------
* |     Smart-Shop开源商城系统/ Java商城-首选电商平台系统 请务必保留此注释头信息
* |     开源地址: https://gitee.com/ningbo-qishan/gruul-mall
* ------------------------------------------------------------------------
* ------------------------------------------------------------------------
* |     可正常分享和学习源码,未经授权 不可商用！
* |     商业版中台购买/开源版商业授权 联系技术客服
* |     官网:  https://www.73app.cn/
* ------------------------------------------------------------------------
* ------------------------------------------------------------------------
* |     Copyright (c) 2016-2999 宁波启山智软科技有限公司
* |     版权所有 ,侵权必究！
* ------------------------------------------------------------------------

*/
package com.medusa.gruul.solitaire.web.controller.manager;

import com.medusa.gruul.common.core.util.PageUtils;
import com.medusa.gruul.common.core.util.Result;
import com.medusa.gruul.solitaire.api.model.dto.manager.InformationMessageDto;
import com.medusa.gruul.solitaire.api.model.param.manager.InformationMessageParam;
import com.medusa.gruul.solitaire.api.model.vo.manager.InformationMessageVo;
import com.medusa.gruul.solitaire.service.manager.IInformationMessageService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 资讯留言信息 前端控制器
 * </p>
 *
 * @author lcysike
 * @since 2021-05-26
 */
@RestController
@RequestMapping("/manager/information/message")
public class InformationMessageController {

    @Autowired
    private IInformationMessageService iInformationMessageService;

    /**
     * 获取资讯留言信息
     */
    @GetMapping("/list")
    @ApiOperation(value = "获取资讯留言信息")
    public Result<PageUtils<InformationMessageVo>> list(InformationMessageParam informationMessageParam) {
        PageUtils<InformationMessageVo> pageUtils = new PageUtils(iInformationMessageService.list(informationMessageParam));
        return Result.ok(pageUtils);
    }

    /**
     * 资讯信息回复
     */
    @PostMapping("/reply")
    @ApiOperation(value = "资讯留言回复)")
    public Result reply(@RequestBody @Validated InformationMessageDto informationMessageDto) {
        iInformationMessageService.reply(informationMessageDto);
        return Result.ok();
    }

    /**
     * 资讯信息设为/取消星标
     */
    @PostMapping("/star")
    @ApiOperation(value = "资讯留言新增/修改(支持批量)")
    public Result star(@RequestBody @Validated InformationMessageDto informationMessageDto) {
        iInformationMessageService.star(informationMessageDto);
        return Result.ok();
    }


    /**
     * 资讯留言排序
     */
    @PutMapping("/sort")
    @ApiOperation(value = "资讯留言排序")
    public Result sort(@RequestBody List<InformationMessageDto> informationMessageDtos) {
        iInformationMessageService.sort(informationMessageDtos);
        return Result.ok();
    }

    /**
     * 资讯留言删除
     */
    @DeleteMapping("/delete/{id}")
    @ApiOperation(value = "资讯留言删除")
    public Result deleteActivity(@ApiParam(value = "资讯留言id", required = true) @PathVariable(name = "id") Long id) {
        iInformationMessageService.delete(id);
        return Result.ok();
    }
}
